//
//  BaseTabBarController.swift
//  GreenDeal
//
//  Created by Moennig Q on 12/12/2022.
//

import UIKit
import Rswift
enum APPModule: String {
    case installation = "Installation"
    case serviceJobs = "Service Jobs"
    case calendar = "Calendar"
}
class BaseTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        //setting
        self.tabBar.barTintColor = UIColor.white
        self.tabBar.tintColor = UIColor(hexStr: Constant.ThemeColorHexStr)
        self.tabBar.unselectedItemTintColor = UIColor(hexStr: "#292D3280")
        self.tabBar.isTranslucent = false
        //
        self.initTabBar()
        
    }
    func initTabBar(){
        
    }
    func  addChildViewController(childerVC:UIViewController,module: APPModule)  {
        
        let tabItem = BaseTabBarItem()
        
        switch module {
        case .installation:
            tabItem.title = APPModule.installation.rawValue
            tabItem.selectedImage = R.image.tabbar_Installations_sel()
            tabItem.image = R.image.tabbar_Installations_unsel()
        case .serviceJobs:
            tabItem.title = APPModule.serviceJobs.rawValue
            tabItem.selectedImage = R.image.tabbar_servicejobs_sel()
            tabItem.image = R.image.tabbar_servicejobs_unsel()
        case .calendar:
            tabItem.title = APPModule.calendar.rawValue
            tabItem.selectedImage = R.image.tabbar_calendar_sel()
            tabItem.image = R.image.tabbar_calendar_unsel()
        }
        
        let naVc = BaseNavigationController()
        
        naVc.tabBarItem = tabItem
        
        naVc.addChild(childerVC)
        
        self.addChild(naVc)
    }
    override func viewWillAppear(_ animated: Bool) {
        self.selectedViewController?.beginAppearanceTransition(true, animated: animated)
    }
    override func viewDidAppear(_ animated: Bool) {
        self.selectedViewController?.endAppearanceTransition()
    }
    override func viewWillDisappear(_ animated: Bool) {
        self.selectedViewController?.beginAppearanceTransition(false, animated: animated)
    }
    override func viewDidDisappear(_ animated: Bool) {
        self.selectedViewController?.endAppearanceTransition()
    }
    

}
